<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>${tabTitle}</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <form id="ins_cfg_info_edit_form">
                    <div class="fieldset1 tabel_col clearFix">
                        <div class="fieldBox col_33">
                            <div class="label">机构名称</div>
                            <div class="field">
                                <span>${fundRasInsNm}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">客户名称</div>
                            <div class="field">
                                <span>${cstNm}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_33">
                            <div class="label">身份证号</div>
                            <div class="field">
                                <span>${certNo}</span>
                            </div>
                        </div>
                         <div class="fieldBox col_33">
                            <div class="label">学历</div>
                             <div class="field">
                                 <select name="highDgCd" id="highDgCd" value="${highDgCd}" >
                                     <c:if test="${highDgCd == null || highDgCd == ''}">
                                         <option value="" selected="selected">--请选择--</option>
                                     </c:if>
                                     <c:if test="${highDgCd != null && highDgCd != ''}">
                                         <option value="">--请选择--</option>
                                     </c:if>
                                     <c:forEach items="${highDgCdList}" var="item">
                                         <c:if test="${item.key == highDgCd}">
                                             <option value="${item.key}" selected="selected">${item.value}</option>
                                         </c:if>
                                         <c:if test="${item.key != highDgCd}">
                                             <option value="${item.key}">${item.value}</option>
                                         </c:if>
                                     </c:forEach>
                                 </select>
                                 <span class="requiredSymbol">*</span>
                             </div>
                        </div>

                    <!-- hide data -->
                    <div class="fieldBox col_100" style="display: none;">
                        <div class="field">
                            <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
                        </div>
                    </div>
                </div>
                <div id="saveInsCfgDiv" class="btnsBox" style="text-align: center">
                    <span id="saveInsCfg" class="sq-button sq-button-round" onclick="return saveInfo();">保存</span>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">

    var detailFlag = '${detailFlag}';
    var fromCAFlag = '${fromCAFlag}';
    var fromCMFlag = '${fromCMFlag}';

    $(function(){

        initData();
        disabledInput();
        enableFields();
    });

    /**
     * 初始化
     */
    function initData() {

        $("#ins_cfg_info_edit_form").ligerForm({
            validate: true
        });
    }
    /**
     * 查看详情页面置灰 不可编辑
     **/
    function disabledInput() {

        if(detailFlag == "true") {

            liger.get("highDgCd").setDisabled();

            $("#saveInsCfgDiv").hide();
        }
    }

    /**
     * 是否展示保存按钮
     **/
    function enableFields() {

        if (null != fromCAFlag && "true" == fromCAFlag) {

            $("#saveInsCfgDiv").show();
        }
        if (null != fromCMFlag && "true" == fromCMFlag) {

            $("#saveInsCfgDiv").show();
        }
    }

    /**
     * 保存表单数据
     */
    function saveInfo(){

        var ligerForm = liger.get("ins_cfg_info_edit_form");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            //验证不通过，不执行以下代码
            return false;
        }

        if(!$("#highDgCd").val()){
            top.$.ligerDialog.SQalert({content: "请选择学历！", SQ_type: "error"});
            return false;
        }

        //系统信息
        var data = ligerForm.getData();
        data["cstId"] = $("#cstId").val();//客户ID
        data["highDgCd"] = $("#highDgCd").val(); //学历

        var url = '<%=path%>/institution/smbc/save.do';

        var wait_dialog;
        $.ajax({
            type:"post",
            url: url,
            data: data,
            dataType:"json",
            async:false,
            cache:false,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {

                    UIUtils.alertSuccessHold1(msg.info);
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }
</script>
</body>
</html>